package com.atguigu.common.exception;

import com.atguigu.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理类/ 全局异常 /自定义异常
 */
@SuppressWarnings("all")
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(ErrorException.class)
    @ResponseBody
    public R error(ErrorException e){
        e.printStackTrace();
        return R.error(e.getCode(),e.getMsg());
    }

}


